//
//  UIView_Kit.swift
//  
//
//  Created by xp on 2023/4/3.
//

import UIKit

public extension UIView {
    
    /// Get the first controller for this view.
    /// (获取该视图的第一个控制器)
    var getFirstViewController: UIViewController? {
        for view in sequence(first: self, next: { $0.superview }) {
            if let responder = view.next {
                if responder.isKind(of: UIViewController.self) {
                    return responder as? UIViewController
                }
            }
        }
        return nil
    }
    
}
